import { unref, computed, h } from 'vue';
import { FormSchema } from '@/components/Form/index';
import { expandAndToString } from '@/utils/common';
import { BasicUpload } from '@/components/Upload';
import { uploadApi, deleteApi } from '@/api/sys/upload';
import { FileInfo } from '@/components/Upload/src/typing';
import { List } from '@/components/Linqts';

// 基础设置 form
export const formSchemas: FormSchema[] = [
  {
    field: 'BgUrl',
    component: 'Input',
    label: '首页背景链接',
    componentProps: {
      placeholder: '请填写',
    },
    required: true,
    colProps: {
      offset: 4,
      span: 12,
    },
  },
  {
    field: 'VinnoVideoImgs',
    component: 'Upload',
    label: '公司宣传视频链接图',
    required: true,
    colProps: {
      offset: 4,
      span: 12,
    },
    rules: [
      {
        required: true,
        message: '请选择 图片格式文件',
      },
    ],
    render: ({ model, field }) => {
      return h(BasicUpload, {
        accept: ['.png', '.jpg', '.gif', '.jpeg', '.bmp', '.ico'],
        maxSize: 10,
        maxNumber: 1,
        value: model[field],
        emptyHidePreview: true,
        api: uploadApi,
        uploadParams: {},
        onChange: (files: FileInfo[]) => {
          model[field] = files;
        },
      });
    },
  },
  {
    field: 'VinnoVideoUrl',
    component: 'Input',
    label: '公司宣传视频链接',
    componentProps: {
      placeholder: '请填写',
    },
    required: true,
    colProps: {
      offset: 4,
      span: 12,
    },
  },
  {
    field: 'VinnoDesc',
    component: 'InputTextArea',
    label: '公司简介',
    required: true,
    componentProps: {
      placeholder: '请填写',
      showCount: true,
      rows: 15,
    },
    colProps: {
      offset: 4,
      span: 12,
    },
  },
  {
    field: 'VinnoInviteImgs',
    component: 'Upload',
    label: '公司招聘图',
    required: true,
    colProps: {
      offset: 4,
      span: 12,
    },
    rules: [
      {
        required: true,
        message: '请选择 图片格式文件',
      },
    ],
    render: ({ model, field }) => {
      return h(BasicUpload, {
        accept: ['.png', '.jpg', '.gif', '.jpeg', '.bmp', '.ico'],
        maxSize: 10,
        maxNumber: 1,
        value: model[field],
        emptyHidePreview: true,
        api: uploadApi,
        uploadParams: {},
        onChange: (files: FileInfo[]) => {
          model[field] = files;
        },
      });
    },
  },
];

export interface SettingInputDto {
  BgUrl: string;
  VinnoVideoImgs: [];
  VinnoVideoUrl: string;
  VinnoDesc: string;
  VinnoInviteImgs: [];
}

export interface SettingOutputDto {
  BgUrl: string;
  VinnoVideoImgs: [];
  VinnoVideoUrl: string;
  VinnoDesc: string;
  VinnoInviteImgs: [];
}
